package wetalk.software.bupt.com.wetalk.util;

import android.util.Log;

import com.github.promeg.pinyinhelper.Pinyin;

/**
 * Created by xiaoma on 2018/1/14.
 */

public class MyPinyinParser {

    public String toSimplePy(String name){//汉字换小写，取简化
        StringBuilder builder=new StringBuilder();
        String pinyin="";
        for (int i = 0; i <name.length() ; i++) {
            char c = name.charAt(i);
            if (Pinyin.isChinese(c)){
                pinyin=Pinyin.toPinyin(c).substring(0,1).toLowerCase();
            } else{
                pinyin=c+"";
            }
            builder.append(pinyin);
        }
        return builder.toString();
    }

    public String toComplexPy(String name){//汉字换小写，取全称
        StringBuilder builder=new StringBuilder();
        String pinyin=new String();
        for (int i = 0; i <name.length() ; i++) {
            char c = name.charAt(i);
            if (Pinyin.isChinese(c)){
                pinyin= Pinyin.toPinyin(c).toLowerCase();
            } else{
                pinyin=c+"";
            }
            builder.append(pinyin);

        }
        return builder.toString();
    }

}
